package com.yiidata.rpc.protobuf;

import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.util.HashMap;
import java.util.Map;

/**
 * <pre>
 *
 * Created by zhenqin.
 * User: zhenqin
 * Date: 2018/1/6
 * Time: 14:47
 * Verdor: NowledgeData
 * To change this template use File | Settings | File Templates.
 *
 * </pre>
 *
 * @author zhenqin
 */
public class ProtobufObjectToBytes {


    public static void main(String[] args) throws Exception {
        ProtobufRpc.User.Builder builder = ProtobufRpc.User.newBuilder();
        builder.setName("ProtobufRPC, User Instance.");

        ProtobufRpc.User user = builder.build();

        byte[] bytes = user.toByteArray();
        System.out.println(bytes.length);

        ProtobufRpc.User user1 = ProtobufRpc.User.parseFrom(bytes);
        System.out.println(user1.getName());
    }
}
